<?php
    class iJValidation{
        
        /**
         *
         * Class Constructuctor
         * @access public
         */
        
        public static function name($value, $minLen = MIN_NAME_LENGHT){
            
            if(!is_int($minLen)) {
              $minLen = MIN_NAME_LENGHT;
            }
            
            if($minLen == 0 && strlen($value) == 0) {
              return true;
            }
            
            if (!preg_match("/^[a-zA-Z0-9_.]+$/", $value)){
                return false;
            } else {
                if (iconv_strlen($value) >= $minLen){ 
                    return true;
                } else {
                    return false;
                }
            }
            
        }
        
        public static function validString($value, $minLen = MIN_NAME_LENGHT){
            
            if(!is_int($minLen)) {
              $minLen = MIN_NAME_LENGHT;
            }
            
            if($minLen == 0 && strlen($value) == 0) {
              return true;
            }
            
            if (!preg_match("/^[a-zA-Z0-9_.,]+$/", $value)){
                return false;
            } else {
                if (iconv_strlen($value) >= $minLen){ 
                    return true;
                } else {
                    return false;
                }
            }
            
        }

       public static function mail($mail){
         //TODO fix mail validation
         if (strlen($mail)==0) {
           return false;
         }
         if (!preg_match("[a-z0-9_-.]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|" .
                         "edu|gov|arpa|info|biz|inc|name|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-" .
                         "9]{1,3}\.[0-9]{1,3})$/is",$mail)) {
           return false;
         }  else {
           return true;
         } 
       }   
       
        public static function number($numb, $minLen = 0){
            //TODO min length property
            /*
            if(!is_int($minLen)) {
              $minLen = MIN_NAME_LENGHT;
            }
            
            if($minLen == 0 && strlen((string)$numb) == 0) {
              return true;
            }*/
            
            if (!preg_match("|^[\d]+$|", $numb)){
                return false;
            } else {
                return true;
            }
       }
       
         public static function Unex_symb($symb, $minLen = 0){
          
            if(!is_int($minLen)) {
              $minLen = MIN_NAME_LENGHT;
            }
            
            if($minLen == 0 && strlen($symb) == 0) {
              return true;
            }
            
            
            if (!preg_match("/[<>!@#$%^&().*{}'\"]+/", $symb)){
                return true;
            } else {
                return false;
            }
       }
       
       
       public static function URL($url) {
        if(preg_match('/^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}'
           .'((:[0-9]{1,5})?\/.*)?$/i' ,$url)) {
              return true;
           } else {
            return false;
           }
       }
        
    }                  

?>